import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// 导入中文语言包
import zhCn from 'element-plus/es/locale/lang/zh-cn'
// 导入全局样式
import '@/assets/styles/global.scss'

const app = createApp(App)

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
// 使用 Element Plus 并配置中文语言
app.use(ElementPlus, {
    locale: zhCn,
})
app.use(router)
app.use(ElementPlus)

// 抑制 ResizeObserver 错误
const originalError = console.error
console.error = (...args) => {
    if (args[0] && typeof args[0] === 'string' && args[0].includes('ResizeObserver')) {
        return
    }
    originalError.apply(console, args)
}

// 或者更精确的抑制方式
window.addEventListener('error', (e) => {
    if (e.message && e.message.includes('ResizeObserver')) {
        e.stopImmediatePropagation()
    }
})

// 挂载应用
app.mount('#app')